<template>
    <div>
        <div class="form-item  form-item-style1">
            <div class="label-title">
                <label>单位名称</label>
            </div>
            <div>
                <p>{{detailObj.CreateDeptName}}</p>
            </div>
        </div>
        <div class="form-item  form-item-style1">
            <div class="label-title">
                <label>职务</label>
            </div>
            <div>
                <p>{{detailObj.Duty}}</p>
            </div>
        </div>
        <div class="form-item  form-item-style1">
            <div class="label-title">
                <label>姓名</label>
            </div>
            <div>
                <p>{{detailObj.CreateUser}}</p>
            </div>
        </div>
        <div class="form-item  form-item-style1">
            <div class="label-title">
                <label>时间</label>
            </div>
            <div>
                <p>{{detailObj.ResumptionDate}}</p>
            </div>
        </div>
        <h2>工作内容（{{detailObj.items?detailObj.items.length:0}}条）</h2>
        <div v-for="(item,index) in detailObj.items"
             :key="index">
            <div class="form-item  form-item-style1"
                 @click="openChild(item)">
                <div class="label-title">
                    <label>{{item.Description}}</label>
                </div>
                <div style="display:flex;align-items: center;">
                    <x-icon type="ios-arrow-down"
                            size="20"
                            class="icon-right"
                            v-show="!item.open"></x-icon>
                    <x-icon type="ios-arrow-up"
                            size="20"
                            class="icon-right"
                            v-show="item.open"></x-icon>
                </div>
            </div>
            <div class="form-section sectionML20"
                 style="border-bottom:1px solid #f4f4f4;"
                 v-show="item.open">
                <div class="form-item form-item-style2">
                    <div class="label-title space-between">
                        <div class="space-between">
                            <label>图片</label>
                        </div>
                        <span>当前共{{item.AttachList.length}}张照片</span>
                    </div>
                    <div class="upload-wrap">
                        <div>
                            <div class="upload-item"
                                 v-for="(item,i) in item.imgList"
                                 :key="i">
                                <img :src="item"
                                     :preview="preview+index"
                                     alt="">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-item  form-item-style1">
                    <div class="label-title">
                        <label>时间</label>
                    </div>
                    <div>
                        <p>{{item.ResumptionTime}}</p>
                    </div>
                </div>
            </div>
        </div>
        <div class="cut-off-rule"></div>
        <div class="form-item form-item-style2">
            <div class="label-title space-between">
                <div class="space-between">
                    <label>工作总结</label>
                </div>
            </div>
            <div>
                <p class="textarea">{{detailObj.JobSummary}}</p>
            </div>
        </div>
    </div>
</template>
<script>
import upload from '@/commonComponents/upload/index'
export default {
    name: 'recordDetail',
    components: {
        upload
    },
    data () {
        return {
            preview: new Date().getTime(), // 预览图片分组
            userInfo: {},
            detailObj: {}
        }
    },
    created () {
        this.userInfo = JSON.parse(localStorage.getItem('userInfo'))
        this.getDetail()
    },
    methods: {
        openChild (item) {
            this.$set(item, 'open', !item.open)
        },
        getDetail () {
            let param = {
                'allowPaging': true,
                'business': 'GetResumptionDetail',
                'data': {
                    'id': this.$route.query.id
                },
                'pageIndex': 0,
                'pageSize': 0,
                'tokenId': this.userInfo.tokenId,
                'userId': this.userInfo.userid
            }
            this.$axiosAjax.getConfigJson(param)
                .then((res) => {
                    if (res.data.code === 0) {
                        this.detailObj = res.data.data
                        this.detailObj.items.forEach(item => {
                            let imgList = []
                            item.AttachList.forEach(imgObj => {
                                imgList.push(imgObj.Url)
                            })
                            this.$set(item, 'imgList', imgList)
                        })
                        this.$previewRefresh()
                    }
                }).catch((response) => {
                })
        }
    }
}
</script>
<style scoped>
h2 {
    width: 100%;
    height: 40px;
    line-height: 40px;
    text-align: right;
    padding-right: 20px;
    box-sizing: border-box;
    background: #ebeef2;
}
.sectionML20 {
    margin-left: 20px;
}
</style>
